package com.waves.design.observer;


/**
 * 具体指挥部类
 * 具体目标类
 * 当它的状态发生改变时将向它的各个观察者发出通知
 */
public class ConcreteAllyControlCenter extends AllyControlCenter{
    public ConcreteAllyControlCenter(String allyName){
        System.out.println(allyName + "战队组件成功");
        System.out.println("-------------");
        this.allyName = allyName;
    }

    public void notifyObserver(String name){
        System.out.println(this.allyName + "战队紧急通知，盟友" + name + "遭受敌人攻击！");
        for(Object obs : players){
            if (!((Observer) obs).getName().equalsIgnoreCase(name)) {
                ((Observer) obs).help();
            }
        }
    }
}
